<?php
/**
 * Copyright (c) Sandeep Manne (sandeep.manne@gmail.com) 
 *
 * @author  Sandeep Manne
 * @since   Nov 1, 2008, 3:46:48 PM
 * @version $Id: cache.php 17 2009-05-22 17:33:25Z sandeep.manne $
 */


/**
 * @see Zend_Config_Ini
 */
require_once 'Zend/Config/Ini.php';
$cacheConfig        = new Zend_Config_Ini(APPLICATION_PATH . '/settings/cache.ini', $settings->application->environment);
$cacheConfig        = $cacheConfig->cache;

$backendAdapter     = $cacheConfig->backend->adapter;
$frontendOptions    = $cacheConfig->frontend->params->toArray();
$backendOptions     = $cacheConfig->backend->params->toArray();

/**
 * @see Zend_Cache
 */
require_once 'Zend/Cache.php';

/**
 * Setting the output cache adapter
 */
$cache        = Zend_Cache::factory($cacheConfig->frontend->adapter,
                                    $backendAdapter,
                                    $frontendOptions,
                                    $backendOptions);
/**
 * Setting the file cache adapter
 */
$cacheFile    = Zend_Cache::factory($cacheConfig->frontend->file->adapter,
                                    $backendAdapter,
                                    array_merge($frontendOptions, $cacheConfig->frontend->file->params->toArray()),
                                    $backendOptions);

/**
 * @see Zend_Registry
 */
require_once 'Zend/Registry.php';
Zend_Registry::set('cache',     $cache);
Zend_Registry::set('cacheFile', $cacheFile);

/**
 * Cleanup temporary page variabls
 */
unset($cacheConfig, $backendAdapter, $frontendOptions, $backendOptions);